package trabajoISW2.tests;

import org.junit.Before;
import org.junit.Test;

import trabajoISW2.domain.contracts.ICreditCard;
import trabajoISW2.domain.exceptions.NoPositiveNumberException;
import trabajoISW2.domain.exceptions.WrongNameException;


public class CreditCardTestSuite {

	ICreditCard id;
	String n1, n2, n3, n4, n5;
	SuperTest st;
	
	@Before
	public void setup(){
		st = new SuperTest();
		st.inicializa();
		id = st.creditCard2;
		n1 = "0000000000000001";
		n2 = "9999999999999999";
		n3 = "0123456789012345";
		n4 = "1";
		n5 = "-1";
		
	}
	
	//Pruebas para el m�todo setType
	
	public void testSetType1(){
		id.setType("visa");
	}
	
	@Test (expected =WrongNameException.class)
	public void testSetType2(){
		id.setType(null);
	}
	
	@Test (expected = WrongNameException.class)
	public void testSetType3(){
		id.setType("");
	}
	
	//Pruebas para el método setNumber
	
	@Test
	public void testSetNumber1(){
		
		id.setNumber(n1);
		id.setNumber(n2);
		id.setNumber(n3);
	}
	
	
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetNumber3(){
		id.setNumber("");
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetNumber4(){
		id.setNumber(null);
	}
	
	
	
	//Pruebas sobre el m�todo setCvv
	
	@Test
	public void testSetCvv1(){
		id.setCvv(000);
		id.setCvv(999);
		id.setCvv(001);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetCvv2(){
		id.setCvv(-1);
	}
	
	@Test(expected = NoPositiveNumberException.class)
	public void testSetCvv3(){
		id.setCvv(1000);
	}
	
	//Pruebas sobre el método setMonth
	
	@Test
	public void testSetMonth(){
		id.setMonth(1);
		id.setMonth(12);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetMonth2(){
		id.setMonth(0);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetMonth3(){
		id.setMonth(-1);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetMonth4(){
		id.setMonth(13);
	}
		//prueba sobre el método setYear
	
	@Test
	public void testSetYear(){
		id.setYear(2011);
		id.setYear(2012);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetYear2(){
		id.setYear(2010);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetYear3(){
		id.setYear(-2010);
	}
	
	
}
